<?php
session_start();
include($_SERVER['DOCUMENT_ROOT'].'/config.php');
$article = $_GET['article'];
$pageid = $_GET['pageid'];
if(!$_SESSION['username']) {
    header('location:../pages/page.php?page=login');
    exit;
}
if($_SESSION['adminrights'] == false) {
    print('<p>You do not seem to have administrative rights, therefore you can not add, edit or delete posts<br>
                       If you are an administrator you might want to <a href="../classes/class.logout.php">logout</a> and login using your administrative account or either go back to <a href="../index.php?page=news">news</a>.</p>');
    exit;
}
else {
    $connect = new mysqli(DB_HOST,DB_USER,DB_PASS,DB_NAME);
    switch($pageid) {
        default;
            $query = $connect->query("DELETE FROM ".$prefix."pages WHERE pageid='".$pageid."'");
            $query2 = $connect->query("DELETE FROM ".$prefix."menu WHERE id='".$pageid."'");
            break;
        case "2";
            $query = $connect->query("DELETE FROM ".$prefix."posts WHERE id='".$article."'");
            break;
    }
    $connect->close();
}
header("location:../");
?>